﻿<UserControl x:Class=" LocultApp.Controls.Exception.ExceptionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             
             xmlns:local="clr-namespace:LocultApp.Local"
             >
    <Grid Grid.Row="1"
          Margin="3,15,3,3">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" xmlns:conv="clr-namespace:LocultApp.Converter" >
                <Grid.Resources>
                    <conv:BoolToVisibilityConverter x:Key="BoolToVis" FalseValue="Collapsed" TrueValue="Visible" />
                </Grid.Resources>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Image Grid.Column="0"
                  ToolTip="{Binding ErrorMessage, Mode=OneWay}"
                  Source="{StaticResource AppMessageError_Image}"
                  Margin="3" />

                <Grid Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBox  Grid.Row="0" Margin="3"
                        Text="{Binding ErrorMessage, Mode=OneWay}" FontSize="24"
                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                        IsReadOnly="True"
                        BorderThickness="0"
                        Background="Transparent"
                    />
                    <TextBox Grid.Row="1" Margin="3"
                         Text="{Binding ErrorTip, Mode=OneWay}" FontSize="14"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         IsReadOnly="True"
                         BorderThickness="0"
                         Background="Transparent"
                         Visibility="{Binding IsErrorTipVisible, Converter={StaticResource BoolToVis}}"
                    />
                </Grid>
                <Button Grid.Column="2"
                        Command="{Binding CloseExceptionViewCommand}"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Background="Transparent"
                        >
                    <Button.Content>
                        <Grid Width="18" Height="16"
                                HorizontalAlignment="Center" VerticalAlignment="Center"
                                RenderTransform="1,0,0,1,0,1">
                            <Path Data="M0,0 L8,7 M8,0 L0,7 Z" Width="8" Height="7"
                                  VerticalAlignment="Center" HorizontalAlignment="Center"
                                  Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
                                  StrokeThickness="2"  />
                        </Grid>
                    </Button.Content>
                </Button>
            </Grid>

            <Expander Header="{x:Static local:Strings.STR_LABEL_Error_Details}" Grid.Row="1" Margin="0, 6, 0, 3">
                <TextBox Text="{Binding ErrorStackTrace, Mode=OneWay}"
                        VerticalAlignment="Stretch"
                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                        IsReadOnly="True"
                        BorderThickness="0"
                        />
            </Expander>
        </Grid>
    </Grid>
</UserControl>
